package de.tabuma.pm.externalproject.controller;

import de.tabuma.pm.*;
import de.tabuma.pm.externalproject.logik.*;
import de.tabuma.pm.externalproject.entity.*;
import de.tabuma.lib.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class list extends tabumacontroller {

    private static final Logger log = Logger.getLogger(list.class.getName());

    public list(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        String projectId = request.getParameter(constants.projectId);
        int projectIdInt = Integer.valueOf(projectId).intValue();

        List<ExternalProject> epList = ExternalProjectFacade.getList(projectIdInt);

        request.setAttribute(constants.ExternalProjectList, epList);

        Hashtable<String,List<Parameter>> hash = new Hashtable<String,List<Parameter>>();
        for(int i=0;i<epList.size();i++) {

            ExternalProject ep = epList.get(i);
            List<Parameter> parameterList = new ArrayList<Parameter>();
            List<HiddenParameter> hiddenList = HiddenParameterFacade.getList(ep.getId().intValue());
            for(int j=0;j<hiddenList.size();j++) {
                parameterList.add(hiddenList.get(j));
            }
            List<LoginUserParameter> userList = LoginUserParameterFacade.getList(ep.getId().intValue());
            for(int j=0;j<userList.size();j++) {
                parameterList.add(userList.get(j));
            }
            hash.put(""+ep.getId(),parameterList);
        }
        request.setAttribute(constants.ParameterList, hash);
    }
}